package com.zzs.gmshop.web;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.zzs.gmshop.entity.User;
import com.zzs.gmshop.manager.UserManager;

public class LoginAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	
	private UserManager userManager;
	
	private String name;
	
	private String password;
	
	private boolean remember;
	
	public String login() {
		User user = userManager.login(name, password);
		if(user != null) {
			if(remember) {
				ActionContext.getContext().getSession().put("login", user);
			}
			return "login_success";
		} else {
			return "login_failure";
		}
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setUserManager(UserManager userManager) {
		this.userManager = userManager;
	}

	public boolean isRemember() {
		return remember;
	}

	public void setRemember(boolean remember) {
		this.remember = remember;
	}

	

}
